package com.obrempon.credit.market.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.obrempon.credit.market.R
import com.obrempon.credit.market.utils.ObremponImageUtil
import com.obrempon.module.adapter.ObremponRecyclerViewAdapter
import com.obrempon.module.adapter.ObremponViewHolderHelper
import com.obrempon.module.shapeview.layout.ShapeLinearLayout
import org.json.JSONObject

/**
 * ObremponCredit
 * @Author wwdeng
 * @CreateTime: 2025/3/25 18:36
 * @Annotation：
 */
class ObremponAuthStepWalletAccountTypeApt(recyclerView: RecyclerView?) : ObremponRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.obrempon_auth_step_wallet_account_type_item) {
    override fun setItemChildListener(helper: ObremponViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.walletTypeLayout) //点击Item
    }
    override fun fillData(helper: ObremponViewHolderHelper, position: Int, model: JSONObject) {
        val isSelect = model.optBoolean("isSelect", false)
        val walletTypeLayout = helper.getView<ShapeLinearLayout>(R.id.walletTypeLayout)
        val imgWalletTypeLogo = helper.getImageView(R.id.imgWalletTypeLogo)
        val textWalletTypeTitle = helper.getTextView(R.id.textWalletTypeTitle)
        textWalletTypeTitle.text = model.optString("desc")
        ObremponImageUtil.instance.loadImageUrl(mContext,imgWalletTypeLogo,model.optString("logo"), R.mipmap.obrempon_holder)

        val imgWalletTypeSelected = helper.getImageView(R.id.imgWalletTypeSelected)
        if (isSelect) {
            walletTypeLayout.shapeDrawableBuilder
                .setStrokeColor(getColor(R.color.color_ff0569ff))
                .setSolidColor(getColor(R.color.color_ffedf2fc))
                .intoBackground()
            textWalletTypeTitle.setTextColor(getColor(R.color.color_ff0569ff))
            imgWalletTypeSelected.setImageResource(R.mipmap.obrempon_auth_step_ocr_delete_information_selected_icon)
        } else {
            walletTypeLayout.shapeDrawableBuilder
                .setStrokeColor(getColor(R.color.color_1a979797))
                .setSolidColor(getColor(R.color.color_1a979797))
                .intoBackground()
            textWalletTypeTitle.setTextColor(getColor(R.color.color_ff7a89a6))
            imgWalletTypeSelected.setImageResource(R.mipmap.obrempon_auth_step_ocr_delete_information_normal_icon)
        }
    }
}